<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>JlCloud 统一认证系统</title>
    <link rel="stylesheet" type="text/css" href="/static/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="/static/css/iofrm-style.css">
    <link rel="stylesheet" type="text/css" href="/static/css/iofrm-theme.css">
</head>
<body>
<div class="form-body">
    <div class="row">
        <div class="form-holder">
            <div class="form-content">
                <div class="form-items">
                    <div class="website-logo-inside">
                        <img class="logo-size" src="/static/images/jlcloud-logo.png">
                        <h1>JlCloud 统一认证系统</h1>
                    </div>
                    <p th:text="'应用 [' + ${client_id} + '] 请求授权'">应用 [未获取到应用信息] 请求授权</p>
                    <p>授权后该应用将取得系统操作权限</p>
                    <div class="page-links">
                        <a th:text="'授权账号 [' + ${username} + '] 请求授权'">授权账号 [未获取到账号信息]</a>
                    </div>
                    <form action="/oauth/authorize/perform" method="post">
                        <input id='approval' name='approval' th:value="${auto_approve}" type='hidden'/>
                        <input id='state' name='state' th:value="${state}" type='hidden'/>
                        <div class="form-button">
                            <button id="submit" type="submit" class="ibtn">同意/授权</button>
                            <button id="logout" class="lbtn">退出登录</button>
                        </div>
                    </form>
                </div>
                <div class="other-links">
                    <span>Copyrights © 2024 <a href="http://www.jilianjituan.com/" target="_blank">JlCloud</a> All Rights Reserved.</span>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="/static/js/jquery.min.js"></script>
<script src="/static/js/popper.min.js"></script>
<script src="/static/js/bootstrap.min.js"></script>
<script>
    $(window).on("load", function () {
       // 初始化页面增加租户id传递
       const state = getUrlParam("state");
       if (state !== null && state !== "") {
           $("#state").val(state);
       }
       // 获取approve的值，如果为true则自动提交表单
       const approve = $("#approval").val();
       if (approve === "true") {
           $("#submit").click();
       }
    });

    $("#logout").click(function(event){
        event.preventDefault();
        window.location.href = "/oauth/authorize/logout";
    });

    // 获取url中参数的值
    function getUrlParam(name) {
        const urlParams = new URLSearchParams(window.location.search);
        return urlParams.get(name);
    }
</script>
</body>
</html>
